package subject_set.weekly_competition.day10_2;

/**
 * @author haomin
 * @date 2022/10/02 10:28
 **/
public class Num2 {
    public static void main(String[] args) {
        maxSum(new int[][]{{6,2,1,3},{4,2,1,5},{9,2,8,7},{4,1,2,9}});
    }
        public static int maxSum(int[][] grid) {
            int max = Integer.MIN_VALUE;
            int m = grid.length, n = grid[0].length;
            for(int i = 0; i < m - 2; ++i){
                for(int j = 0; j < n - 2; ++j){
                    int sum = grid[i][j] + grid[i][j+1] + grid[i][j+2] + grid[i+1][j+1] + grid[i+2][j] +grid[i+2][j+1] + grid[i+2][j+2];
                    max = Math.max(max, sum);
                }
            }
            return max;
        }

}